<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // let xhr = new XMLHttpRequest();
        // console.log(xhr);
        // xhr.open('GET','https://api.adicw.cn/comic/getComicTopThree',true);

        // xhr.send();

        // xhr.onreadystatechange = function(){
        //     if ( xhr.status == 200 && xhr.readyState == 4) {
        //        let data = JSON.parse(xhr.response);
        //        console.log(data);
        //     }else if(xhr.status != 200 && xhr.readyState == 4){
        //         console.log('请求失败');
        //     }
        // }

            function getajax(url){
                let xhr = new XMLHttpRequest();
                console.log(xhr);
                xhr.open('GET',url);
                xhr.send();
                xhr.onreadystatechange=function(){
                    if (xhr.status == 200 && xhr.readyState==4) {
                        let data = JSON.parse(xhr.response);
                        console.log(data);
                    }else{
                        console.log('请求失败');
                    }
                }

            }

         let a = getajax('https://api.apiopen.top/getJoke?page=1&count=2&type=video');
        
            console.log(a);

    </script>
    
</body>
</html>